
"""
    解析yaml文件
"""
import yaml
import os

dic=[]
def json_txt(dic_json,p_key=''):
    if isinstance(dic_json,dict):
        for key in dic_json:
            if isinstance(dic_json[key],dict):
                st=dic_json[key]
                if p_key=='':
                    p_key=key
                else:
                    p_key=p_key+"."+key
                json_txt(st,p_key)
            else:
                key_name=p_key + '.' + key
                dic.append((f'{key_name}',dic_json[key]))

curPath = os.path.dirname(os.path.realpath(__file__))
yamlPath = os.path.join(curPath, "cfgyaml.yaml")
f = open(yamlPath, 'r', encoding='utf-8')
d = yaml.load(f,yaml.FullLoader)
json_txt(d)
print(dic)
